import sys
# a = 10
# print(type(a))
# #这里的a可以直接赋值，一个变量是可以改变类型的，而不是像C/C++一样
# a = 'hello world'
# print(type(a))

#通过'''对字符串进行多行的赋值'''
# a = '''
# first line
# second line
# third line
# '''
# print(a)

# #混合打印
# name = '张三'
# age = 20
# print(f'{name} is {age} years old')

# num = input('请输入一个数字')
# #输入的类型是字符串
# print(type(num))
# print(num)

# #我们可以通过强制类型转换来转换类型
# a = input('输入一个数字')
# a = int(a)
# print(type(a))
# print(a)


# a = int(input('输入一个数字\n'))
# print(type(a))
# print(a)

#python中的运算符的特殊
# a = 12
# b = 3
# #这里的除是带着小数的
# print(a / b)
# print(a // b)
# print(a ** b)
#
# c = 3.1
# print(a / c)


#由于无法保证完全保证精度，所以小数之间的比较是有问题的，不符合我们预期的，但是不影响
# a = 0.1
# b = 0.2
# c = 0.3
# print(a+b == c)
# print(a+b)
# print(c)


# a = 10
# b = 20
# #这里可以直接交换两数
# a,b = b,a
# print(a)
# print(b)

# choice = input('你在大学期间会认真学习吗: 0 -> 不会 1 -> 会\n')
# if choice == '1':
#     print('你会考研上岸或者找到一份好的工作')
# elif choice == '0':
#     print('你只能下工地做劳工')
# else:
#     print('输入有误，退出程序')
#     sys.exit(0)


# #判断一个数字是否是奇数
# a = int(input('输入一个数字，判断奇数\n'))
# if a % 2 == 1:
#     print('奇数')
# else:
#     print('偶数')


# a = -1
# #验证负数取模之后是否是正数
# print(a % 2)

# #判断一年是否是闰年
# year = 2023
# if((year % 4  ==0 and year % 100 != 0) or year % 400 == 0):
#     print('闰年')
# else :
#     print('平年')


# #打印1到10数字
# num = 1
# while num <= 10:
#     print(num)
#     num += 1
#
# for i in range(1,11):
#     print(i)


# #打印5的阶乘
# num = 5
# res = 1
# while num>0:
#     res *= num
#     num -= 1
# print(f'result = {res}')


# #打印1到5的阶乘
# num = 1
# ret = 0
# while num<=5:
#     tmp = 1
#     #计算一次阶乘
#     res = 1     #计算当次的结果
#     while tmp <= num:
#         res *= tmp
#         tmp += 1
#     num += 1
#     ret += res
# print(ret)


#使用for

# for i in range(1,11):
#     print(i,end=" ")

# #打印偶数
# for i in range(2,11,2):
#     print(i,end=" ")


#逆序打印10到1
# for i in range(10,0,-1):
#     print(i,end=" ")


#打印1到100的和
# res = 0
# for i in range(1,101,1):
#     res += i
# print(f'res = {res}')

# #使用函数进行计算
# def Add(x,y):
#     return x + y
# print(Add(1,2))


#计算1到10，1到100，1到1000的求和
# def Sum(begin,end):
#     res = 0
#     for i in range(begin,end,1):
#         res += i
#     return res
#
# print(Sum(1,10))
# print(Sum(1,100))
# print(Sum(1,1000))


#函数的递归调用
# def Fib(i):
#     if i == 1 or i == 2:
#         return 1
#     return Fib(i-1) + Fib(i-2)
#
# print(Fib(1))
# print(Fib(2))
# print(Fib(3))
# print(Fib(4))
# print(Fib(5))
# #递归太深，计算时间很久
# print(Fib(40))


#默认参数和变长参数
# def Sum(x,y = 1):
#     return x+y
# print(Sum(1,10))

#边长参数的本质其实是使用元组来接收参数

# def Sum(*arg):
#     n = len(arg)
#     for i in range(n):
#         print(arg[i])
# Sum(1,2,4,6)

# a = []
# print(type(a))
#
# a = [1,2,3,4,5,6]
# print(a)

# #列表是没有不限数据类型的
# l = [1,2,3,4,5]
# l.append('nihao')
# l.append('hello')
# print(l)


# l = [1,2,3,4,5]
# l.insert(1,0)
# #这里不怕越界，相当于尾插
# l.insert(100,23)
# print(l)


# l = [1,3,4,5]
# l.pop()
# print(l)


# a = [1,3,4,5,5]
# #这里只会删除第一个
# a.remove(5)
# print(a)


# a = [1,3,5,6]
# print(1 in a)
# print(3 not in a)


# a = [1,3,5,6]
# print(a.index(3))

# a = [2,4,5,2,6]
# print(a[3]) #2

# #负索引
# a = [2,3,6,2,6]
# print(a[-1])


# a = [1,3,36,26,7,43]
# #并不会影响值，这里只是遍历
# for e in a:
#     e += 4
# print(a)
#
# #使用下标索引的方式就会改变
# for i in range(len(a)):
#     a[i] += 3
# print(a)


# a = [23,3,5,6,72,3]
# i = 0
# while i<len(a):
#     a[i] = 1
#     i += 1
# print(a)

# a = [1,3,4,25,36]
# print(a[2:3])

#a = [1,2,3,4,5,6,7,8,9]
# print(a[::1])
# print(a[::2])
# print(a[::3])
# print(a[::-1])
#越界不会报错
# print(a[1:100:1])


